#include "StorageFuncService.h"
#include <json/json.h>
#include "utils/Defs.h"

SNB_SRV_BEGIN

Json::Value StorageFuncService::getAllDiskInfo()
{
    Json::Value status;
    status["diskNums"] = "4";
    status["diskUuid"] = "system-uuid-123";

    Json::Value diskInfoList(Json::arrayValue);

    Json::Value disk1;
    disk1["diskUuid"] = "uuid-1";
    disk1["diskSize"] = 2147483648; // 2GB
    disk1["diskFreeSize"] = 536870912; // 512MB
    disk1["powerTime"] = 12345;
    disk1["diskState"] = "NORMAL";

    Json::Value disk2;
    disk2["diskUuid"] = "uuid-2";
    disk2["diskSize"] = 4294967296; // 4GB
    disk2["diskFreeSize"] = 1073741824; // 1GB
    disk2["powerTime"] = 67890;
    disk2["diskState"] = "WARNING";

    diskInfoList.append(disk1);
    diskInfoList.append(disk2);
    status["diskInfoList"] = diskInfoList;

    return status;
}

std::string StorageFuncService::getAllDiskNames()
{
    return "[\"sda\", \"sdb\", \"sdc\"]";
}

std::vector<std::string> StorageFuncService::getAllDiskUuids()
{
    return {"uuid-1", "uuid-2", "uuid-3"};
}

Json::Value StorageFuncService::getDiskInfoByUuid(const std::string &uuid)
{
    if (uuid == "uuid-1") {
        Json::Value disk;
        disk["diskUuid"] = "uuid-1";
        disk["diskSize"] = 2147483648;
        disk["diskFreeSize"] = 536870912;
        disk["powerTime"] = 12345;
        disk["diskState"] = "NORMAL";
        return disk;
    } 
    else if (uuid == "uuid-2") {
        Json::Value disk;
        disk["diskUuid"] = "uuid-2";
        disk["diskSize"] = 4294967296;
        disk["diskFreeSize"] = 1073741824;
        disk["powerTime"] = 67890;
        disk["diskState"] = "WARNING";
        return disk;
    }
    
    return Json::Value(); // 返回空JSON表示未找到
}

std::string StorageFuncService::getDiskStateByUuid(const std::string &uuid)
{
    if (uuid == "uuid-1") return "NORMAL";
    if (uuid == "uuid-2") return "WARNING";
    return "";
}

SNB_SRV_END